package com.example.sys.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.sys.entity.Post;
import com.example.sys.mapper.PostMapper;
import com.example.sys.service.PostService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sys.vo.PostVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 岗位信息表 服务实现类
 * </p>
 *
 * @author anan
 * @since 2019-06-20
 */
@Service
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements PostService {

    @Autowired
    private PostMapper postMapper;

    @Override
    public IPage<Post> selectPage(PostVo postVo) {
        IPage<Post> iPage = new Page<>(postVo.getPage(),postVo.getLimit());
        QueryWrapper<Post> wrapper = new QueryWrapper<>();
        if (!StrUtil.hasEmpty(postVo.getPostName()))
            wrapper.like("post_name", postVo.getPostName());
        if (!StrUtil.hasEmpty(postVo.getPostCode()))
            wrapper.like("post_code",postVo.getPostCode());
        if (!StrUtil.hasEmpty(postVo.getStatus()))
            wrapper.like("status",postVo.getStatus());
        return postMapper.selectPage(iPage, wrapper);
    }
}
